#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
// #define int long long
#define endl '\n'
#define P pair<int, int>
#define x first
#define y second
constexpr int maxl = 1e6 + 7;

int n;
vector<int> G[maxl];
int sz[maxl];
int u_ans = maxl, t_ans;
queue<int> q;
bool vis[maxl];
int dis[maxl];

void dfs(int u, int fa) {
  sz[u] = 1;
  int weight = 0;
  for (const auto& v : G[u]) {
    if (v == fa) continue;;
    dfs(v, u);
    sz[u] += sz[v];
    weight = max(weight, sz[v]);
  } 

  weight = max(weight, n - sz[u]);
  if (weight <= n / 2) {
    u_ans = min(u, u_ans);
  }
}

void solve() {
  cin >> n;
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);

  q.push(u_ans);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 1;

    t_ans += dis[u];

    for (const auto& v : G[u]) {
      if (vis[v]) continue;;
      q.push(v);
      dis[v] = dis[u] + 1;
    }
  }

  cout << u_ans << " " << t_ans << endl;
}

signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int t = 1;
  // cin >> t;
  while(t--) solve();
  return 0;
}